
<%var csstpl = {%>
    <link href="${basepath}/vendor/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <style>
    	* { outline:none; }
    	li { list-style:none; }
		a{ color: #337ab7;text-decoration: none;}
    	.hide { display:none; }
    	.clear { clear:both; margin:0; }
    	.search_panel { position:relative; margin-bottom:20px; padding:15px; background:#fff; border: 1px solid #e7eaec; border-radius:3px; }
    	.search_panel .part1 { width:250px; border:0px solid #f00; }
    	.search_panel .part1 label { position:relative; display:block; margin:20px 0; padding-right:160px; text-align:right; }
    	.search_panel .part1 input { position:absolute; right:0; top:-5px; width:150px; padding:6px; font:13px/15px "微软雅黑"; border:1px solid #ddd; border-radius:3px; }
    	.search_panel .part2 { position:absolute; left:300px; top:17px; border:0px solid #f00; }
    	.search_panel .part2 label { position:relative; display:block; margin:10px 0; padding-right:160px; }
    	.search_panel .part2 input { width:150px; padding:6px; font:13px/15px "微软雅黑"; border:1px solid #ddd; border-radius:3px; }
    	.search_panel .part2 select { width:150px; padding:5px; font:12px/15px "微软雅黑"; border:1px solid #ddd; border-radius:3px; }
    	.search_panel .btns { padding:10px 0 0 100px; }
    	.search_panel .btns .btn.color { font:13px/20px "微软雅黑"; margin-right:5px; padding:3px 20px; background:#1AB394; color:#fff; border:1px solid #1AB394; }
    	.search_panel .btns .btn.line  { font:13px/20px "微软雅黑"; margin-right:5px; padding:3px 20px; background:#ffffff; color:#333; border:1px solid #ddd; }

    	.list { position:relative; margin-top:60px; background:#fff; border: 1px solid #e7eaec; border-radius:3px; }
    	.list .menu { position:absolute; left:0; top:-42px; padding:0; }
    	.list .menu li { float:left; margin-left:-1px; }
    	.list .menu li a { display:block; width:80px; padding:0; background:#F8F8F8; font:13px/40px "微软雅黑"; color:#333; text-align:center; border:1px solid #e7eaec; }
    	.list .menu li.active a { background:#fff; border-bottom:1px solid #fff; }
    	.list .contt { padding:15px; }

    	table { width:100%; }
    	table td2 { padding:20px; background:#f8f8f8; border: 2px solid #fff; vertical-align:top; }
    	table tbody { margin:10px 0; border:1px solid #F8F8F8; }
    	table tbody tr.title { border:1px solid #e7eaec; }
    	table tbody tr.title td { padding:12px; background:#f8f8f8; vertical-align:top; }
    	table tbody tr.sep { height:10px; }
    	table tbody tr.remark { border:1px solid #e7eaec; }
    	table tbody tr.remark td { padding:10px; color:#f33; }
    	table tbody tr.info { border:1px solid #e7eaec; background:#F8F8F8; }
    	table tbody tr.info td { padding:10px; }
    	table tbody tr.detail { padding-top:10px; }
    	table tbody tr.detail td { padding:12px; vertical-align:top; border:1px solid #e7eaec; }
    	table tbody tr.detail td b { font-weight:normal; margin-right:8px; }
    	table tbody tr.detail td .btn { font:13px/20px "微软雅黑"; margin-right:5px; padding:3px 20px; background:#ffffff; color:#333; border:1px solid #ddd; }
    	table tbody tr.detail td.td1 img { float:left; width:80px; margin-right:12px; }
    	table tbody tr.detail td.td1 .name { font:14px/1.5em "微软雅黑"; margin-bottom:8px; display:block; }
    	table tbody tr.detail td.td1 p { font:14px/1.5em "微软雅黑"; color:#999; margin:0; }
    	table tbody tr.detail td.td2 { width:100px; text-align:center; }
    	table tbody tr.detail td.td3 { width:100px; text-align:center; }
    	table tbody tr.detail td.td4 { width:100px; text-align:center; }
    	table tbody tr.detail td.td5 { width:150px; }
    	table tbody tr.detail td.td6 { width:100px; text-align:center; }
    	table tbody tr.detail td.td7 { width:120px; text-align:center; }
    	table tbody tr.detail td.td7 a { font:14px/1.5em "微软雅黑"; margin-bottom:10px; display:block; }
    	table tbody tr.detail td.td8 { width:150px; text-align:center; }
    	table tbody tr.detail td.td9 { width:120px; text-align:center; }

    	.send_contt { display:none; }
    	.send_panel div.bind { position:relative; padding-left:60px; margin-bottom:10px; }
    	.send_panel div.bind label { position:absolute; left:0; font:14px/35px "微软雅黑"; }
    	.send_panel div.bind input { display:block; width:100%; padding:5px; border:1px solid #e5e5e5; border-radius:3px; font:14px/20px "微软雅黑"; }
    	.send_panel div.bind select { display:block; width:100%; padding:5px; border:1px solid #e5e5e5; border-radius:3px; font:14px/20px "微软雅黑"; }

    	.new-info { color:#1ab394; }
    	.empty { height:400px; background:url(/static/vendor/img/order_empty.png) no-repeat center; }
    </style>
<%};%>
<%var jstpl = {%>
    <script src="${basepath}/vendor/script/Ajax.web.1.0.3.js"></script>
    <script src="${basepath}/vendor/script/order.js?v=21"></script>
    <script>
      $(function(){
    	  $("#refund${refund!0}").addClass("active");
      })
    </script>
<%};%>
<%layout("../layout/_layout_mall.html",{title:'小金娱',jstpl:jstpl,csstpl:csstpl}){ %>

    <div class="wrapper wrapper-content  ">
    	<form method="post" id="search" action="/system/order/refundList">
    	<!-- 搜索面板 -->
    	<div class="search_panel">
    		<div class="part1">
    		  <label>订单号：<input type="text" value="${order.id!}" name="order.id" /></label>
    		  <label>收货人姓名：<input type="text" value="${order.express_receive_name!}" name="order.express_receive_name"  /></label>
    		  <label>收货人手机：<input type="text" value="${order.express_phone!}"  name="order.express_phone"  /></label>
    		</div>
    		<div class="part2">
    		  <label>支付订单： <input type="text" /></label>
    		  <label>订单状态：
    		    	<#select attr='   id="type_id"   name="order.state"     '  value="${order.state!+''}"  listdata="${state_list!}" text="state_name" key="state_id" />
    		  </label>
    		  <label>下单时间： <input type="text" id="start" name="start_time" value="${start_time!}" class="date1" /> 至 <input id="end" name="end_time" value="${end_time!}" type="text" class="date2" /></label>
    		</div>
    		<div class="btns">
    		  <a href="javascript:;" type="submit" class="btn color">筛选</a>
    		 <!--  <a href="javascript:;" class="btn line">批量导出</a>
    		  <a href="javascript:;" class="btn line">查看已生成报表</a> -->
    		  <a href="javascript:;" class=" excel  btn line">订单导出</a>
    		  <!-- <a href="javascript:;" class=" excel_detail   btn line">订单详细导出(附有商品)</a> -->
    		</div>
    		<!--  </form>  -->
    	</div>

    	<!-- 订单列表 -->
    	<div class="list">
	      <ul class="menu">
	        <li id="refund0" ><a href="/system/order/refundList?refund=0">全部</a></li>
	        <%for(r in @AppConst.Item_Refund_State){%>
	        	<%if(!rLP.first){%>
					<li id="refund${r.key!}"><a href="/system/order/refundList?refund=${r.key!}">${r.value!}</a></li>
	        	<%}%>
	        <%}%>
	      </ul>
	      <div class="contt">
	    	<!-- <div class="empty"></div> -->
	    	<table>
	    	<tr class="title"><td>商品</td><td>单价/数量</td> <td>售后</td> <td>运费</td>   <td>订单金额</td>    <!-- <td>涨价或减价</td> --><td>配送地址</td><td>下单时间</td><td>收件人</td><td>订单状态</td></tr>
	    	<!-- fang  2016-06-22 -->
	    	<%  for( order in order_list){  %>
	    	<tbody data-id="${order.id!}">
	    	<tr class="sep"><td colspan="8"></td></tr>
	    	<tr class="info"><td colspan="7">订单号：${order.id!}</td><td colspan="2" align="right"><a href="/system/order/detail/${order.id!}">订单详情</a>  - <a href="javascript:;" class="btn_remark" data-remark="${order.admin_remark!}">备注</a></td></tr>
	    	<%  for( orderItem in order.item  ){  %>
	    	<input type="hidden" id="item_id" value="${orderItem.item_id!}" />
	    	<input type="hidden" id="refund_state" value="${orderItem.refund_state!}" />
	    	<% if(orderItemLP.first) {  %>
	    	<tr class="detail">
	    	  <td class="td1" data-id="${orderItem.item_id!}">
	    	  <img src="${orderItem.image_center!}?imageView2/1/w/200/h/200" />
	    	  <a href="javascript:;" class="name">${orderItem.product_name!}</a>
	    	  <p><b>${orderItem.sku_text!}</b>
	    	   <% if(isNotEmpty(orderItem.sku_text))  {  %>
	    	   <a href="javascript:;" class="btn_sku">修改</a>
	    	   <%  }  %>
	    	   </p>
	    	  </td>
	    	  <td class="td2">
	    	  <%  if(isNotEmpty(orderItem.sku_price))  {  %>
	    	  <p>${orderItem.sku_price!}</p>
	    	  <%  }else {  %>
	    	  <p>${orderItem.product_price!}</p>
	    	  <%  }  %>
	    	  <p>${orderItem.nums!} 件</p></td>
	    	 <td class="td8" >
	    	  	<% if(orderItem.refund_state!=1){ %>
	    	  	<a href="/system/order/refund_detail/${orderItem.item_id}" class="">${@AppConst.Refund_State.get(orderItem.refund_state!)}</a>
	    	  	<%}%>
	    	  </td>
	    	   <td class="td3" rowspan="${order.item.~size!}"><p>${order.express_amount!0}</p>
	    	    <% if(order.state==0){  %>
	    	    <a href="javascript:;" class="list_btn_postFee ">修改</a>
	    	    <%  }  %>
	    	   </td>
	    	  <td class="td4" rowspan="${order.item.~size!}"><p>${order.total_amount!0}</p></td>
	    	  <td class="td5" rowspan="${order.item.~size!}"><p><b>${order.express_address!}</b><a href="javascript:;" class="btn_addr">修改</a></p></td>
	    	  <td class="td6" rowspan="${order.item.~size!}">${order.createtime,"yyyy-MM-dd HH:mm:ss"}</td>
	    	  <td class="td7" rowspan="${order.item.~size!}"><!-- <a href="javascript:;">老罗</a> --><p>${order.express_receive_name!}</p><p>${order.express_phone!}</p></td>

	    	  <td class="td9" rowspan="${order.item.~size!}" >
	    	    <p>${@AppConst.Procuct_State.get(order.state+'')}</p>
	    	  </td>
	    	</tr>
	    	<% }else{  %>
	    	<tr class="detail">
	    	  <td class="td1">
	    	  <img src="${orderItem.image_center!}?imageView2/1/w/200/h/200" />
	    	  <a href="javascript:;" class="name">${orderItem.product_name!}</a>
	    	  <p><b>${orderItem.sku_text!}</b>
	    	   <%  if(isNotEmpty(orderItem.sku_text) ) {  %>
	    	  <a href="javascript:;" class="btn_sku">修改</a>
	    	  <% }  %>
	    	  </p>
	    	  </td>
	    	  <td class="td2">
	    	  <%  if(isNotEmpty(orderItem.sku_price))  {  %>
	    	  <p>${orderItem.sku_price!}</p>
	    	  <%  }else {  %>
	    	  <p>${orderItem.product_price!}</p>
	    	  <%  }  %>

	    	  <p>${orderItem.nums!} 件</p></td>
	    	   	 <td class="td8" >
	    	  	<% if(orderItem.refund_state!=1){ %>
	    	  	<a href="/system/order/refund_detail/${orderItem.item_id}" class="">${@AppConst.Refund_State.get(orderItem.refund_state!)}</a>
	    	  	<%}%>
	    	  </td>
	    	</tr>
	    	<%  }  %>
	    	<%  }  %>
	    	<!-- 备注为不为空 -->
	    	 <%  if(isNotEmpty(order.user_remarks) ){  %>
	    	<tr class="remark"><td colspan="9">${order.user_remarks!}</td></tr>
	    	<%  }  %>
	    	</tbody>

             <%  }  %>
	    	<!-- - -->
	    	</table>
	    	<!-- <form  method="post"  action="/system/order"  >  -->
	    	<div class="send_contt">
	    	<div class="bind">
	    	  <label>选快递</label>
	    	  <select>
	    	  <option value="">请选择</option>
	    	  <%  for(express in @AppConst.Express){  %>
	    	  <option value="${express.key!}">${express.value!}</option>
	    	  <%  }  %>
	    	  </select>
	    	</div>
	    	<div class="bind">
	    	  <label>订单号</label>
	    	  <input type="text" placeholder="请输入" />
	    	</div>

	    	</div>

          </div>
           <%  if(isEmpty(order_list) ){  %>
          <div class="empty"></div>
          <%  }  %>
        </div>
         <%include("/jsp/_paginate_mall.html"){}%>
	  </form>
    </div>


  <!-- 物流查询 -->
<!-- Modal_a -->
     <div class="modal fade" id="myModal_a" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
         <div class="modal-dialog modal-md" role="document">
           <div class="modal-content">
             <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">物流信息</h4>
             </div>
             <div class="modal-body row">
    	          <div class="col-md-12 col-xs-12">
                     <div class="col-md-2 col-xs-5">
                          <p class="row">快递公司：</p>
                     </div>
                     <div class="col-md-10 col-xs-7">
                          <p class="row express_name">顺丰快递</p>
                     </div>
                  </div>
                  <div class="col-md-12 col-xs-12">
                     <div class="col-md-2 col-xs-5">
                          <p class="row">发货单号：</p>
                     </div>
                     <div class="col-md-10 col-xs-7">
                          <p class="row  express_no  ">20160627141700001</p>
                     </div>
                  </div>
                  <div class="col-md-12 col-xs-12">
                     <div class="col-md-2 col-xs-5">
                          <p class="row">发货时间：</p>
                     </div>
                     <div class="col-md-10 col-xs-7">
                          <p class="row express_time">2016-06-26 10:00</p>
                     </div>
                  </div>
                  <ul  id="tbody_body" class="col-md-12 col-xs-12 row info-list">
                  <!-- 这个必须要 -->
                     <li class="col-md-12 col-xs-12">
                        <div class="col-md-2 col-xs-5">
                             <p class="row notice_express">2016-6-25 4:00</p>
                        </div>
                        <div class="col-md-10 col-xs-7">
                             <p class="row ">商家正通知快递公司揽件</p>
                        </div>
                     </li>
                 </ul>
            </div>
             <div class="modal-footer">
                <button type="button" class="btn btn-default btn-close" data-dismiss="modal">关闭</button>
            </div>
           </div>
         </div>
   </div>

<%}%>

<script>
$(function(){

/* 	oid = 0;
	$(".btn-send").click(function(){
		oid = $(this).parents("tbody").data("id");
	});

	$('#myModal').on('show.bs.modal', function(){
		url = "/static/server/proc.json";
		Ajax(url,function(ret){
			if( ret.state )
			{

			}
			else
			{
				layer.msg(ret.msg);
				$('#myModal').modal("hide");
			}
		});
	});
	 */
	var start={elem:"#start",
			format:"YYYY-MM-DD hh:mm:ss",
			max:"2099-06-16 23:59:59",
			istime:true,istoday:false,
			choose:function(datas)
			{end.min=datas;end.start=datas}};

	var end={elem:"#end",format:"YYYY-MM-DD hh:mm:ss",
			//min:laydate.now(),
			max:"2099-06-16 23:59:59",
			istime:true,istoday:false,
			choose:function(datas)
			{start.max=datas}
		};
	laydate(start);
	laydate(end);
})


$(".btn_refund").click(function(){
	var order_id=$(this).attr("data-id");
	var btn=$(this);
	gx.confirm("您是否确定退款？",function(){
		url = "/system/order/refund/"+order_id;
		//data = {"order_id":oid,"express_name":express_name,"express_no":express_no};
		Ajax(url,function(ret){
			if( ret.state ){
				//去掉按钮
				//$("#btn"+oid).hide();
				btn.hide();
				$(".refund"+order_id).text("已经退款处理");
				layer.closeAll();
			}
			else{
				layer.msg(ret.msg);
			}
		});

		})
	})


	  //物流   方    2016-06-28
        $(".express_search").click(function(){
        	//取得订单号
        	var order_id=$(this).attr("data-id");
        	var express_name=$(this).attr("data-express-name");
        	var express_no=$(this).attr("data-express-no");
        	var express_time=$(this).attr("data-express-time");
        	$(".express_name").text(express_name);
        	$(".express_no").text(express_no);
        	$(".express_time").text(express_time);
        	$(".notice_express").text(express_time);
        	$.ajax({
        		cache : true,
        		type : "post",
        		url : "/api/express",
        		data:{"order_id":order_id},
        		//data:$('#static_table').serialize(),
        		//data:{"service":service,"team_category":team_category,"people_num":people_num,"district_id":district_id},// 你的formid
        		async : false,
        		error : function(request) {
        			alert("Connection error");
        		},
        		success : function(d) {
        			console.info(d);
        			console.info(JSON.parse(d.content));
        			//layer.msg("请求成功成功!");
        			var gettpl = $("#detail").html();
        			laytpl(gettpl).render(JSON.parse(d.content), function(html) {
        				$('#tbody_body').html(html);
        			});
        			//弹框
        			$('#myModal_a').modal('show');
        		}
        	});
        })

//xu 2016-08-02 申请退款处理
$(".btn_handle").click(function(){
	var item_id=$("#item_id").val();
	var refund_state=$("#refund_state").val();
layer.open({
	  content: '您是否同意买家的退款申请？'
	  ,btn: ['同意', '拒绝']
	  ,yes: function(){
		  gx.ajax("/system/order/refundManage/refund_ok?item_id="+item_id+"&refund_state="+refund_state,function(d){
			   if(d.state){
				   layer.alert("操作成功!");
				   top.location.reload();
			   }else{
				   layer.msg(d.msg);
			   }
		   },function(e){
			//  alert("错了了")
		   })
		  //window.location.href="/system/order/refundManage/refund_ok?item_id="+item_id;
		  //layer.alert("同意成功",10);
	  },btn2: function(index, layero){
		  gx.ajax("/system/order/refundManage/refund_no?item_id="+item_id+"&refund_state="+refund_state,function(d){
			   if(d.state){
				   layer.alert("操作成功!");
				   top.location.reload();
			   }else{
				   layer.msg(d.msg);
			   }
		   },function(e){
			//  alert("错了了")
		   })
		  //window.location.href="/system/order/refundManage/refund_no?item_id="+item_id;
		  //layer.alert("拒绝成功",10);
	  },cancel: function(){

	  }
	});
});




//订单导出    fang   2016-08-26
  $(".excel").click(function(){
    var data=$("form").serialize();
    //alert(data);
    window.location.href="/system/excel/order/refund_order?"+data;
 	})



</script>


 <script id="detail" type="text/html">
{{# for(var i = 0, len = d.length; i < len; i++){ }}
{{#  if(i==d.length-1){    }}
         <li class="col-md-12 col-xs-12 new-info">
                        <div class="col-md-3 col-xs-5">
                             <p class="row">{{d[i].time}}</p>
                        </div>
                        <div class="col-md-9 col-xs-7">
                             <p class="row">{{d[i].content}}</p>
                        </div>
         </li>

{{# }else{   }}
        <li class="col-md-12 col-xs-12 ">
                        <div class="col-md-3 col-xs-5">
                             <p class="row">{{d[i].time}}</p>
                        </div>
                        <div class="col-md-9 col-xs-7">
                             <p class="row">{{d[i].content}}</p>
                        </div>
         </li>
{{#  }  }}

{{# } }}

</script>
